package main

import (
	"fmt"
	"os"
	"os/signal"
	"syscall"
	"zinxtcp/server"
	handler2 "zinxtcp/test/handler"
)

func main() {
	signChannel := make(chan os.Signal, 1)
	signal.Notify(signChannel, syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM)

	server := server.NewServer("")

	server.AddRouter(1000, &handler2.PingHandler2{})
	server.AddRouter(1002, &handler2.HelloZinxHandler2{})

	err := server.Serve()
	if err != nil {
		goto EXIT
	}
	for {
		select {
		case <-signChannel:
			fmt.Println("Get shutdown sign")
			goto EXIT
		}
	}

EXIT:
	server.Stop()
	fmt.Println("main Server shutdown 6666666666666666666666666")
}
